package com.jn.glide.views;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Handler;
import android.os.Message;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.jn.glide.R;
import com.jn.glide.adapter.TitlesAdapter1;
import com.jn.glide.adapter.TitlesAdapter2;
import com.jn.glide.base.BaseActivity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import retrofit2.http.GET;

public class RetrofitGlide2Activity extends BaseActivity {
    private RecyclerView mRecyclerView;
    private static List<RetrofitGlideActivity.Entity1.Data2> mList;
    private static TitlesAdapter2 mAdapter;

    @Override
    public int getLayoutId() {
        return R.layout.activity_avatar;
    }

    @Override
    public void init() {
        RetrofitGlideActivity.Entity1.Data data = (RetrofitGlideActivity.Entity1.Data) this.getIntent().getSerializableExtra("bean");
        mRecyclerView = findViewById(R.id.recycler);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
        mRecyclerView.setLayoutManager(linearLayoutManager);
        if (data != null && data.list != null && data.list.size() > 0) {
            mList = data.list;
        }
        mAdapter = new TitlesAdapter2(mList);
        mRecyclerView.setAdapter(mAdapter);
        mAdapter.addItemClickListener(new TitlesAdapter2.OnItemClickListener() {
            @Override
            public void onItemClick(RetrofitGlideActivity.Entity1.Data2 item) {
                Intent intent = new Intent(RetrofitGlide2Activity.this, ImagerActivity.class);
                intent.putExtra("url", item.icon);
                startActivity(intent);
            }
        });
    }
}
